<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .item{
            width:300px;
            height: 0px;
            background: #000;

            /* 希望经过3秒  背景颜色  从   #000 --- #fff */
            /* animation: myan 1.6s   forwards; */
        }

       

        .ani{
            animation: myan 1s  reverse ;
        }

        .leave{
            animation: myan 1s  ;
        }

        @keyframes myan {
            from{
                background: #000;
                height: 300px;
            }

            to{
                background: #fff;
                height: 0;
            }
        }



    </style>
</head>
<body>

    <div class="container" 
        onmouseenter="mounseEnver()"
        onmouseleave="mouseLeave()"
        
        style="cursor: pointer;">
            手机(鼠标放我上)
     </div>


    <div class="item">

    </div>
    
   

    <script>
        function mounseEnver(){
            const item = document.querySelector(".item");
            item.className = 'item ani'
        }

        function mouseLeave(){
            const item = document.querySelector(".item");
            item.className = 'item leave'
        }
    

    </script>
    
</body>
</html>